home *** CD-ROM | disk | FTP | other *** search
Wrap
XSetup plugin | 2004-02-21 | 6.0 KB | 229 lines
"FILE"="Xteq Systems X-Setup Plugin 5.0" "TYPE"="9" "COUNT"="1" "UIPATH 1"="Startup/Shutdown\Startup\Windows 9x/ME\80) Windows Launch" "UIPATH 2"="Startup/Shutdown\Startup\Windows NT/2K/XP\60) Windows Launch" "NAME"=""StartUp" Group (All Users)" "LANGUAGE"="VBScript" "VERSION"="2.02" "TEXT 1"="dⁿdel dumm" "DESCRIPTION 1"="This plug-in lets you control which programs are currently inside the "StartUp" folder of your Start Menu." "DESCRIPTION 2"="All items inside this folder are automatically executed when Windows starts." "DESCRIPTION 2"="To prevent an item from starting, disable the checkbox next to it." "DESCRIPTION 3"="Please note: This plug-in will create a folder "Disabled" in your "StartUp" group where all disabled items are stored. Once you have enabled those items again, this "Disabled" folder is deleted." "DESCRIPTION 4"="To add an item to this list, just point your mouse to this folder in your Start Menu, right-click and select "Open". Next, right-click again and select "New" -> "Shortcut"." "AUTHOR"="Xteq Systems" "CONTACTURL"="http://www.xteq.com/" "COPYRIGHT"="Copyright ⌐ Xteq Systems - All Rights Reserved" "COMMENT 1"="Thanks to G÷ran ┼berg [abbe.ema@home.se] for the idea" ' Where to find the Startup Folder: sV1="HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Common Startup" Dim iFiles 'conatins how many are currently displayed in the UI Dim aryFiles() 'contains all the files Dim sPathActive Dim sPathInactive Sub Plugin_Initialize s=RegReadValue(sV1) if len(s)<=0 then Call Disable else if right(s,1)="\" then s=left(s,len(s)-1) end if sPathActive=s ' create the inactive path iPos=InStrRev(sPathActive,"\") if iPos>0 then sName=Right(sPathActive,len(sPathActive)-iPos) sPath=Left(sPathActive,iPos) sPathInactive=sPath & "Disabled " & sName & " Items" Call ReadFiles else Call Disable() Call MsgError("Unable to retrieve name of Startup Group - can not continue") end if end if End Sub Sub ReadFiles 'first, clear the UI for l=1 to iFiles Call SetUIElement(l,"") next 'read active items dim aryTemp1 i=FileEnum(sPathActive & "\*.*") ReDim aryTemp1(i) for l=1 to i s=FileEnumElement(l) if CheckDesktopIni(s)=false then aryTemp1(l)=s next 'read inactive items dim aryTemp2 i=FileEnum(sPathInactive & "\*.*") ReDim aryTemp2(i) for l=1 to i s=FileEnumElement(l) if CheckDesktopIni(s)=false then aryTemp2(l)=s next '--------------------------------------- 'okay, we now have two arrays (aryTemp2 and aryTemp4) that contain 'all the items that we need. We now simply need to create ONE array from those two iFiles=uBound(aryTemp1)+UBound(aryTemp2) ReDim aryFiles(iFiles) for l=1 to UBound(aryTemp1) aryFiles(l)=aryTemp1(l) next for i=1 to UBound(aryTemp2) aryFiles(UBound(aryTemp1)+i)=aryTemp2(i) next '--------------------------------------- 'finally, update the UI for l=1 to UBound(aryFiles) sItem=aryFiles(l) iPos=InStrRev(sItem,"\") if iPos>0 then sName=Right(sItem,len(sItem)-iPos) else sName=sItem end if bActivated=0 if InStr(sItem,sPathInactive)>0 then bActivated=false else bActivated=true end if Call SetUIElement(l,sName) Call SetUIElementEx(l,bActivated) next End Sub Sub Plugin_Apply(ElementIndex,ElementSubIndex) bChanges=false for l=1 to UBound(aryFiles) sItem=aryFiles(l) bUI=GetUIElementEx(l) if InStr(sItem,sPathInactive)>0 then bActive=false else bActive=true end if 'now check for differences between bReg and bUI if bUI=true and bActive=true then 'do nothing, both activated else if bUI=false and bActive=false then 'do nothing, both deactivated else if bUI=true and bActive=false then 'in UI activated, in STARTUP Deactivated -> sOldPath=sItem sNewPath=Replace(sOldPath,sPathInactive,sPathActive) else 'in UI deactivated, in STARTUP activated -> sOldPath=sItem sNewPath=Replace(sOldPath,sPathActive,sPathInactive) end if 'DebugMsg sOldPath & " ** " & sNewPath 'delete any existing file... If FileExists(sNewPath)=true then Call FileDelete(sNewPath) end if 'does disabled folder exist? If FolderExists(sPathInactive)=false then Call FolderCreate(sPathInactive) end if 'copy file Call FileCopy(sOldPath,sNewPath) Call FileDelete(sOldPath) 'check if we can remove the disabled folder... i=FileEnum(sPathInactive & "\*.*") if i<=0 then 'folder empty.. Call FolderDelete(sPathInactive) end if 'set flag bChanges=true end if end if next if bChanges=true then Call ReadFiles 'call the holy Windows API Call IndicateSettingChange() end if End Sub Sub Plugin_Terminate End Sub Function CheckDesktopIni(InStr) CheckDesktopIni=false if len(InStr)>11 then 'length of DESKTOP.INI iPos=InStrRev(InStr,"\") if iPos>0 then sName=Right(InStr,len(InStr)-iPos) else sName=InStr end if if UCase(sName)="DESKTOP.INI" then CheckDesktopIni=true end if end if End Function